import 'package:aweb5/generated/json/mission_detail_entity_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:aweb5/custom/dashed_rect.dart';
import 'package:configurable_expansion_tile/configurable_expansion_tile.dart';
import 'package:bubble/bubble.dart';
import 'package:aweb5/util/NaviUtil.dart';
import 'PhotoViewGalleryScreen.dart';
//import 'package:fluttertoast/fluttertoast.dart';
import 'package:aweb5/util/toast_util.dart';
import 'dart:async';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:aweb5/util/DialogUtil.dart';
import 'package:aweb5/style.dart';
import 'package:aweb5/util/DialogUtil.dart';
import 'package:popup_window/popup_window.dart';
import 'package:load/load.dart';
import 'package:aweb5/util/HttpClient.dart';
import 'package:aweb5/util/HttpUtils1.dart';
import 'package:aweb5/Constants.dart';
import 'package:aweb5/config/Config.dart';
import 'package:aweb5/bean/aplus/mission_detail_entity.dart';
import 'package:aweb5/bean/aplus/group_plan_list_entity.dart';
import 'package:aweb5/bean/aplus/task_detail_list_entity.dart';
import 'package:aweb5/bean/aplus/task_detail_list_entity.dart';
import 'package:aweb5/generated/json/task_detail_list_entity_helper.dart';
import 'package:aweb5/util/DialogUtil.dart';
import 'package:aweb5/widgetlib/menu_widget.dart';
import 'package:aweb5/pages/video_page.dart';
import 'package:aweb5/pages/PhotoViewGalleryScreen.dart';
import 'package:video_player/video_player.dart';
import 'package:aweb5/util/DateUtil.dart';
import 'dart:io';
import 'package:aweb5/pages/plan_detail.dart';
import 'package:aweb5/util/BussinussUtil.dart';
import 'package:aweb5/bean/aplus/somebody_official_plan_entity.dart';
import 'package:aweb5/generated/json/somebody_official_plan_entity_helper.dart';
class UnedittableDashList extends StatefulWidget {
//  GroupPlanListEntity groupPlanListEntity;
   List<SomebodyOfficialPlanDataSendTask> taskSend;
//  GroupPlanListDataMember groupPlanListDataMember = null;
//  GroupPlanListDataFollow followdata = null;

  List<DropdownMenuItem<String>> sortItems = [];
  String selectedSort = "";
  Function refreshCall;
  String groupId = "";
  String url;
  UnedittableDashList(this.taskSend,
      {this.sortItems, this.selectedSort, this.refreshCall, this.groupId,this.url});

  @override
  _UnedittableDashListState createState() => _UnedittableDashListState();
}

class _UnedittableDashListState extends State<UnedittableDashList> {
  List<GlobalKey> key = List();
  SlidableController slidableController;

//  List<String> list = List();

//  List<List<GlobalKey>> k = List();

  List<double> heights = List();
  BuildContext context;

  List<String> images = List();

  List<Widget> widgets = List();
//  Map<int,List<Widget>> widgetMap = Map();

  bool hasFollowOfficial = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    initData();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      update();
    });
  }

  void initData() {
    print("initdata");

    for (int i = 0; i < widget.taskSend.length; i++) {
      key.add(GlobalKey());
//      list.add("呵呵呵${i}");
//      print("${key[i].toString()}");
//      List<GlobalKey> gk = List();
//      for (int j = 0; j < 10; j++) {
//        gk.add(GlobalKey());
//      }
//      k.add(gk);

      heights.add(ScreenUtil().setHeight(80 * 10).toDouble());

      for (int j = 0; j < widget.taskSend[i].info.length; j++) {
        if (widget.taskSend[i].info[j].type == 2) {
          if (widget.taskSend[i].info[j].data.startsWith("http")) {
            widget.taskSend[i].info[j].setController(
                VideoPlayerController.network(widget.taskSend[i].info[j].data));
          } else {
            widget.taskSend[i].info[j].setController(VideoPlayerController.file(
                File(widget.taskSend[i].info[j].data)));
          }
        }
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    this.context = context;
    return Scaffold(
      backgroundColor: Color(0xfff9f9f9),
      body: level1(),
    );
  }

  Widget level1() {
    return ListView.builder(
      itemBuilder: (con, ind) {
        return level2(ind);
      },
//      itemCount: 0,
      itemCount: widget.taskSend == null ? 0 : widget.taskSend.length,
    );
  }

  @override
  dispose() {
    timer.cancel();
    for (int i = 0; i < widget.taskSend.length; i++) {
      for (int j = 0; j < widget.taskSend[i].info.length; j++) {
        if (widget.taskSend[i].info[j].type == 2) {
          if (widget.taskSend[i].info[j].controller != null) {
            widget.taskSend[i].info[j].controller.dispose();
          }
        }
      }
    }
    super.dispose();

//    for (GroupPlanListDataTimeDataTaskSendInfo detailTemp in widget.info) {
//      if (detailTemp.controller != null) {
//        detailTemp.controller.dispose();
//      }
//    }
  }

  Widget level2(int ind1) {
    return Stack(
      children: <Widget>[
        Positioned(
          child: Container(
            color: Color(0xfff9f9f9),
            width: ScreenUtil().setWidth(414 - 43),
            child: content(ind1),
          ),
          left: ScreenUtil().setWidth(43),
          top: 0,
        ),
        Positioned(
          child: Container(
            width: ScreenUtil().setWidth(43),
            color: Color(0xfff9f9f9),
            child: Column(
//            key: key[ind],
              children: <Widget>[
                Image.asset(
                  widget.taskSend[ind1].isSend == 1?
                  "assets/assist/grayr.png":"assets/assist/redr.png",
                  width: ScreenUtil().setWidth(20),
                  height: ScreenUtil().setHeight(20),
                ),
//                LayoutBuilder(builder: (con, box) {
////                print("${box.maxHeight}");
////                print("${box.minHeight}");
//                  return Text("");
//                }),
                Container(
                  alignment: Alignment.center,
                  width: ScreenUtil().setWidth(43),
                  height: heights[ind1],
                  child: new Container(
                    color: Colors.transparent,
                    width: ScreenUtil().setWidth(1),
                    height: heights[ind1],
                    child: DashedRect(
                        color: widget.taskSend[ind1].isSend == 1
                            ? Color(0xff979797)
                            : Color(0xffF94F68),
                        strokeWidth: ScreenUtil().setWidth(1),
                        gap: 3.0),
                  ),
                  color: Color(0xfff9f9f9),
                ),
                Container(
                  width: ScreenUtil().setWidth(ind1==widget.taskSend.length-1?26:0),
                  height: ScreenUtil().setHeight(7),
                  color: Color(0xffF94F68),


                )
              ],
            ),
          ),
        ),
      ],
    );

//    Row(
//      children: <Widget>[
//        Stack(
//          children: <Widget>[
//            Positioned(
//              child: Container(
//                width: ScreenUtil().setWidth(Para.width),
//              ),
//            ),
//
////            Positioned(child: Text("呵呵")),
//            Positioned(
//              child: Container(
//                color: Colors.white,
//                width: ScreenUtil().setWidth(Para.width - 43),
//                child: ListView.builder(
//                  padding: EdgeInsets.all(0),
//                  key: key[ind1],
//                  physics: NeverScrollableScrollPhysics(),
//                  shrinkWrap: true,
//                  itemBuilder: (con, ind) {
//                    return item1(ind, ind1);
//                  },
//                  itemCount: 10,
//                ),
//              ),
//              left: ScreenUtil().setWidth(43),
//              top: 0,
//            ),
//            Positioned(
//              child: Container(
//                width: ScreenUtil().setWidth(43),
//                child: Column(
////            key: key[ind],
//                  children: <Widget>[
//                    Image.asset(
//                      "assets/ab.png",
//                      width: ScreenUtil().setWidth(20),
//                      height: ScreenUtil().setHeight(20),
//                    ),
//                    LayoutBuilder(builder: (con, box) {
////                print("${box.maxHeight}");
////                print("${box.minHeight}");
//                      return Text("");
//                    }),
//                    Container(
//                      alignment: Alignment.center,
//                      width: ScreenUtil().setWidth(43),
//                      height: heights[ind1],
//                      child: new Container(
//                        width: ScreenUtil().setWidth(2),
//                        height: heights[ind1],
//                        child: DashedRect(
//                            color: Color(0xff979797),
//                            strokeWidth: ScreenUtil().setWidth(0.5),
//                            gap: 3.0),
//                      ),
//                      color: Colors.white,
//                    )
//                  ],
//                ),
//              ),
//            ),
//          ],
//        )
//      ],
//    );
//    Row(
//      crossAxisAlignment: CrossAxisAlignment.start,
//      children: <Widget>[
//        Container(
//          width: ScreenUtil().setWidth(43),
//          child: Column(
////            key: key[ind],
//            children: <Widget>[
//              Image.asset(
//                "assets/ab.png",
//                width: ScreenUtil().setWidth(20),
//                height: ScreenUtil().setHeight(20),
//              ),
//              LayoutBuilder(builder: (con, box) {
////                print("${box.maxHeight}");
////                print("${box.minHeight}");
//                return Text("");
//              }),
//              Container(
//                alignment: Alignment.center,
//                width: ScreenUtil().setWidth(43),
//                height: heights[ind1],
//                child: new Container(
//                  width: ScreenUtil().setWidth(2),
//                  height: heights[ind1],
//                  child: DashedRect(
//                      color: Color(0xff979797),
//                      strokeWidth: ScreenUtil().setWidth(0.5),
//                      gap: 3.0),
//                ),
//                color: Colors.white,
//              )
//            ],
//          ),
//        ),
//        Expanded(
//            child: ListView.builder(
//              padding: EdgeInsets.all(0),
//              key: key[ind1],
//              physics: NeverScrollableScrollPhysics(),
//              shrinkWrap: true,
//              itemBuilder: (con, ind) {
//                return item1(ind, ind1);
//              },
//              itemCount: 10,
//            )),
//      ],
//    );
  }

  Widget content(int ind) {
    return Column(
      key: key[ind],
      children: <Widget>[
        Container(
          alignment: Alignment.topLeft,
          width: ScreenUtil().setWidth(414 - 43),
          height: ScreenUtil().setHeight(50),
          color: Color(0xfff9f9f9),
//        color: Colors.amber,
          child: Row(
            children: <Widget>[
              SizedBox(
                width: ScreenUtil().setWidth(7),
              ),
              Text(
                "${widget.taskSend[ind].sendTime}",
                style: TextStyle(
                  color: Color(0xff101010),
                  fontWeight: FontWeight.bold,
                  fontSize: ScreenUtil().setSp(14),
                ),
                textAlign: TextAlign.start,
              )
            ],
          ),
        ),
        Container(
          color: Color(0xfff9f9f9),
          child: Column(
//        key: key[ind],
            children: <Widget>[
              ConfigurableExpansionTile(
//                key: k[ind1][ind],
                borderColorStart: Color(0xfff9f9f9),
                borderColorEnd: Color(0xfff9f9f9),
                expandedBackgroundColor: Colors.white,
//          animatedWidgetFollowingHeader: Image.asset(
//            "assets/ab.png",
//            width: ScreenUtil().setWidth(20),
//            height: ScreenUtil().setHeight(20),
//          ),
                headerExpanded: Container(
                  width: ScreenUtil().setWidth(349),
                  height: ScreenUtil().setHeight(80),
                  child: slide(ind),
                ),
                header: Container(
                  width: ScreenUtil().setWidth(349),
                  height: ScreenUtil().setHeight(80),
                  child: slide(ind),
                ),
                headerBackgroundColorStart: Color(0xfff9f9f9),
//          expandedBackgroundColor: Colors.amber,
                headerBackgroundColorEnd: Color(0xfff9f9f9),

                children: buildList(ind),
//                widget.taskSend[ind].info.map(g).toList(),
//                [
//                  Container(
//                    color: Colors.white,
//                    width: ScreenUtil().setWidth(349),
//                    child: expandItem(),
//                  ),
//                ],
                onExpansionChanged: (b) {},
              )
            ],
          ),
        )
      ],
    );

    if (ind == 0) {
      return Container(
        alignment: Alignment.topLeft,
        width: ScreenUtil().setWidth(414 - 43),
        height: ScreenUtil().setHeight(50),
        color: Color(0xfff9f9f9),
//        color: Colors.amber,
        child: Row(
          children: <Widget>[
            SizedBox(
              width: ScreenUtil().setWidth(7),
            ),
            Text(
              "呵呵",
              style: TextStyle(
                color: Color(0xff101010),
                fontWeight: FontWeight.bold,
                fontSize: ScreenUtil().setSp(14),
              ),
              textAlign: TextAlign.start,
            )
          ],
        ),
      );
    }

    return Container(
      color: Color(0xfff9f9f9),
      child: Column(
//        key: key[ind],
        children: <Widget>[
          ConfigurableExpansionTile(
//            key: k[ind1][ind],
            borderColorStart: Color(0xfff9f9f9),
            borderColorEnd: Color(0xfff9f9f9),
            expandedBackgroundColor: Colors.white,
//          animatedWidgetFollowingHeader: Image.asset(
//            "assets/ab.png",
//            width: ScreenUtil().setWidth(20),
//            height: ScreenUtil().setHeight(20),
//          ),
            headerExpanded: Container(
              width: ScreenUtil().setWidth(349),
              height: ScreenUtil().setHeight(80),
              child: slide(ind),
            ),
            header: Container(
              width: ScreenUtil().setWidth(349),
              height: ScreenUtil().setHeight(80),
              child: slide(ind),
            ),
            headerBackgroundColorStart: Color(0xfff9f9f9),
//          expandedBackgroundColor: Colors.amber,
            headerBackgroundColorEnd: Color(0xfff9f9f9),

            children: [
              Container(
                color: Colors.white,
                width: ScreenUtil().setWidth(349),
                child: expandItem(),
              ),
//              Row(
//                children: <Widget>[
//                  SizedBox(
//                    width: ScreenUtil().setWidth(19),
//                  ),
//                  Image.asset(
//                    "assets/ab.png",
//                    width: ScreenUtil().setWidth(50),
//                    height: ScreenUtil().setWidth(50),
//                  ),
//                  GestureDetector(
//                    child: Bubble(
//                      margin: BubbleEdges.only(top: 10),
//                      nip: BubbleNip.leftTop,
//                      color: Color(0xff8DFA69),
//                      child: Image.asset("assets/ab.png",
//                          width: ScreenUtil().setWidth(50),
//                          height: ScreenUtil().setWidth(50)),
//                    ),
//                    onTap: () {
//                      NaviUtil.push(
//                          this.context,
//                          PhotoViewGalleryScreen(
//                            images: images,
//                            index: 0,
//                          ));
//                    },
//                  )
//                ],
//              ),
//              Row(
//                children: <Widget>[
//                  SizedBox(
//                    width: ScreenUtil().setWidth(19),
//                  ),
//                  Image.asset(
//                    "assets/ab.png",
//                    width: ScreenUtil().setWidth(50),
//                    height: ScreenUtil().setWidth(50),
//                  ),
//                  Expanded(
//                      child: GestureDetector(
//                        child: Bubble(
//                          margin: BubbleEdges.only(top: 10),
//                          nip: BubbleNip.leftTop,
//                          color: Color(0xff8DFA69),
//                          child: Text(
//                              'Hello, World!111111111111111111111111111111111111',
//                              textAlign: TextAlign.right),
//                        ),
//                        onTap: () {
//                          Fluttertoast.showToast(msg: "tab");
////                    print("tab");
//                        },
//                      ))
//                ],
//              ),
            ],
            onExpansionChanged: (b) {},
          )
        ],
      ),
    );
  }
//  Widget item2( int ind,int ind1) {
//    if (ind == 0) {
//      return Container(
//        alignment: Alignment.topLeft,
//        width: ScreenUtil().setWidth(414 - 43),
//        height: ScreenUtil().setHeight(50),
//        color: Color( 0xfff9f9f9),
////        color: Colors.amber,
//        child: Row(
//          children: <Widget>[
//            SizedBox(
//              width: ScreenUtil().setWidth(7),
//            ),
//            Text(
//              "呵呵",
//              style: TextStyle(
//                  color: Color(0xff101010),
//                  fontWeight: FontWeight.bold,
//                  fontSize: ScreenUtil().setSp(14),
//              ),
//              textAlign: TextAlign.start,
//            )
//          ],
//        ),
//      );
//    }
//
//    return
//    Container(
//      color: Color(0xfff9f9f9),
//      child: Column(
////        key: key[ind],
//        children: <Widget>[
//          ConfigurableExpansionTile(
//            key: k[ind1][ind],
//            borderColorStart: Color(0xfff9f9f9),
//            borderColorEnd: Color(0xfff9f9f9),
//            expandedBackgroundColor:Colors.white,
////          animatedWidgetFollowingHeader: Image.asset(
////            "assets/ab.png",
////            width: ScreenUtil().setWidth(20),
////            height: ScreenUtil().setHeight(20),
////          ),
//            headerExpanded: Container(
//              width: ScreenUtil().setWidth(349),
//              height: ScreenUtil().setHeight(80),
//              child: slide(ind),
//            ),
//            header: Container(
//              width: ScreenUtil().setWidth(349),
//              height: ScreenUtil().setHeight(80),
//              child: slide(ind),
//            ),
//            headerBackgroundColorStart: Color(0xfff9f9f9),
////          expandedBackgroundColor: Colors.amber,
//            headerBackgroundColorEnd: Color(0xfff9f9f9),
//
//            children: [
//
//              Container(
//                color: Colors.white,
//                width: ScreenUtil().setWidth(349),child: expandItem(),)
//              ,
////              Row(
////                children: <Widget>[
////                  SizedBox(
////                    width: ScreenUtil().setWidth(19),
////                  ),
////                  Image.asset(
////                    "assets/ab.png",
////                    width: ScreenUtil().setWidth(50),
////                    height: ScreenUtil().setWidth(50),
////                  ),
////                  GestureDetector(
////                    child: Bubble(
////                      margin: BubbleEdges.only(top: 10),
////                      nip: BubbleNip.leftTop,
////                      color: Color(0xff8DFA69),
////                      child: Image.asset("assets/ab.png",
////                          width: ScreenUtil().setWidth(50),
////                          height: ScreenUtil().setWidth(50)),
////                    ),
////                    onTap: () {
////                      NaviUtil.push(
////                          this.context,
////                          PhotoViewGalleryScreen(
////                            images: images,
////                            index: 0,
////                          ));
////                    },
////                  )
////                ],
////              ),
////              Row(
////                children: <Widget>[
////                  SizedBox(
////                    width: ScreenUtil().setWidth(19),
////                  ),
////                  Image.asset(
////                    "assets/ab.png",
////                    width: ScreenUtil().setWidth(50),
////                    height: ScreenUtil().setWidth(50),
////                  ),
////                  Expanded(
////                      child: GestureDetector(
////                        child: Bubble(
////                          margin: BubbleEdges.only(top: 10),
////                          nip: BubbleNip.leftTop,
////                          color: Color(0xff8DFA69),
////                          child: Text(
////                              'Hello, World!111111111111111111111111111111111111',
////                              textAlign: TextAlign.right),
////                        ),
////                        onTap: () {
////                          Fluttertoast.showToast(msg: "tab");
//////                    print("tab");
////                        },
////                      ))
////                ],
////              ),
//
//            ],
//            onExpansionChanged: (b) {},
//          )
//        ],
//      ),
//    )
//
//      ;
//  }

  List<Widget> buildList(int ind) {
//    return g(widget.taskSend[ind], ind)

    List<Widget> list = List();
    for (int i = 0; i < widget.taskSend[ind].info.length; i++) {
      list.add(g(widget.taskSend[ind].info[i], ind));
    }
    return list;
  }

  Widget expandItem() {
    return Container(
      width: ScreenUtil().setWidth(349),
      child: Row(
        children: <Widget>[
          SizedBox(
            width: ScreenUtil().setWidth(19),
          ),
          Image.asset(
            "assets/ab.png",
            width: ScreenUtil().setWidth(50),
            height: ScreenUtil().setWidth(50),
          ),
          Bubble(
            margin: BubbleEdges.only(top: 10),
            nip: BubbleNip.leftTop,
            color: Color(0xff8DFA69),
            child: Text('Hello, World!', textAlign: TextAlign.right),
          ),
        ],
      ),
    );
  }

  Widget g(SomebodyOfficialPlanDataSendTaskInfo info, int ind) {
//    int index = widget.taskSend.indexOf(element).info.indexOf(info);
    //图片
    if (info.type == 1) {
      return Container(
        width: ScreenUtil().setWidth(349),
        child: Row(
          children: <Widget>[
            SizedBox(
              width: ScreenUtil().setWidth(19),
            ),
            CircleAvatar(
              radius: ScreenUtil().setWidth(22.5),
              backgroundImage: NetworkImage(widget.url
//                widget.followdata,
              ),
            ),
            Expanded(
                child: GestureDetector(
                  child: Bubble(
                    margin: BubbleEdges.only(top: 10),
                    nip: BubbleNip.leftTop,
                    color: Color(0xff8DFA69),
                    child: Image.network(
                      info.data,
//                width: ScreenUtil().setWidth(50),
//                height: ScreenUtil().setWidth(50),
                    ),
                  ),
                  onTap: () {
                    List<String> img = List();
//      widget.taskSend[ind].info
                    for (int i = 0; i < widget.taskSend[ind].info.length; i++) {
                      if (widget.taskSend[ind].info[i].type == 1) {
                        img.add(widget.taskSend[ind].info[i].data);
                      }
                    }

                    NaviUtil.push(
                        this.context,
                        PhotoViewGalleryScreen(
                          images: img,
                          index: 0,
                        ));
                  },
                )),
          ],
        ),
      );
    }
    //视频
    if (info.type == 2) {
      return Container(
        width: ScreenUtil().setWidth(349),
        child: Row(
          children: <Widget>[
            SizedBox(
              width: ScreenUtil().setWidth(19),
            ),
            CircleAvatar(
              radius: ScreenUtil().setWidth(22.5),
              backgroundImage: NetworkImage(widget.url
//                widget.followdata,
              ),
            ),
            Expanded(
                child: GestureDetector(
                  child: Bubble(
                    margin: BubbleEdges.only(top: 10),
                    nip: BubbleNip.leftTop,
                    color: Color(0xff8DFA69),
                    child: v(info),
                  ),
                  onTap: () {
                    List<String> img = List();
//      widget.taskSend[ind].info
                    for (int i = 0; i < widget.taskSend[ind].info.length; i++) {
                      if (widget.taskSend[ind].info[i].type == 1) {
                        img.add(widget.taskSend[ind].info[i].data);
                      }
                    }

                    NaviUtil.push(this.context, VideoPage(info.data));
                  },
                )),
          ],
        ),
      );

      Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Expanded(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  SizedBox(
                    width: ScreenUtil().setWidth(19),
                  ),
                  CircleAvatar(
                    radius: ScreenUtil().setWidth(25),
                    backgroundImage: NetworkImage(
                      widget.url,
                    ),
                  ),
                  Expanded(
                      child: GestureDetector(
                        child: Bubble(
                            margin: BubbleEdges.only(top: 10),
                            nip: BubbleNip.leftTop,
                            color: Color(0xff8DFA69),
                            child: v(info)
//                              videoView()
//                                  Container(width: 100,height: 200,child:videoView() ,)

//                              Padding(
//                                padding: const EdgeInsets.all(10.0),
//                                child: AspectRatioVideo(_controller),
//                              )
//          Image.asset("assets/ab.png",
//              width: ScreenUtil().setWidth(50),
//              height: ScreenUtil().setWidth(50)),
                        ),
                        onTap: () {
                          NaviUtil.push(this.context, VideoPage(info.data));
                        },
                      )),
                  SizedBox(
                    width: ScreenUtil().setWidth(15),
                  ),
                ],
              )),
        ],
      );
    }
    //文字
    if (info.type == 3) {
      return Container(
        width: ScreenUtil().setWidth(349),
        child: Row(
          children: <Widget>[
            SizedBox(
              width: ScreenUtil().setWidth(19),
            ),
            CircleAvatar(
              radius: ScreenUtil().setWidth(22.5),
              backgroundImage: NetworkImage(widget.url),
            ),
            Expanded(
                child: Bubble(
                  margin: BubbleEdges.only(top: 10),
                  nip: BubbleNip.leftTop,
                  color: Color(0xff8DFA69),
                  child: Text(
                    '${info.data}',
                    textAlign: TextAlign.left,
                  ),
                )),
          ],
        ),
      );
    }
    //链接
    if (info.type == 4) {
      return Container(
        width: ScreenUtil().setWidth(349),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(
              width: ScreenUtil().setWidth(19),
            ),
            CircleAvatar(
              radius: ScreenUtil().setWidth(22.5),
              backgroundImage: NetworkImage(widget.url),
            ),
            Expanded(
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
//                    SizedBox(
//                      width: ScreenUtil().setWidth(19),
//                    ),
//                    CircleAvatar(
//                      radius: ScreenUtil().setWidth(25),
//                      backgroundImage: NetworkImage(widget.url
////    widget.groupPlanListDataMember.headimgurl,
//
//                      ),
//                    ),
                    Expanded(
                        child: GestureDetector(
                          child: Bubble(
                              margin: BubbleEdges.only(top: 10),
                              nip: BubbleNip.leftTop,
                              color: Color(0xff8DFA69),
                              child: Container(
                                width: ScreenUtil().setWidth(215),
                                height: ScreenUtil().setHeight(60),
                                child: Row(
                                  children: <Widget>[
                                    Image.network(
                                      (BussinussUtil.parseLink(info.data, "img_url")
                                      as String),
                                      width: ScreenUtil().setWidth(50),
                                      height: ScreenUtil().setHeight(50),
                                    ),

                                    SizedBox(width: ScreenUtil().setWidth(10),),
                                    Expanded(
                                        child: Column(
                                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: <Widget>[
                                            Text(
                                              (BussinussUtil.parseLink(info.data, "title")
                                              as String),
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                            Row(
                                              mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                              children: <Widget>[
                                                Text(
                                                  (BussinussUtil.parseLink(info.data, "y")
                                                  as String),
                                                  style: TextStyle(color: Colors.grey),
                                                ),
                                              ],
                                            )
                                          ],
                                        )),
                                    SizedBox(
                                      width: ScreenUtil().setWidth(2),
                                    ),
//                                  Container(
//                                    width: ScreenUtil().setWidth(65),
//                                    height: ScreenUtil().setHeight(60),
//                                    alignment: Alignment.center,
//                                    decoration: redButtonStyleWithBorder,
//                                    padding: EdgeInsets.symmetric(
//                                        vertical: ScreenUtil().setHeight(5)),
//                                    child: Column(
//                                      mainAxisAlignment:
//                                      MainAxisAlignment.spaceBetween,
//                                      children: <Widget>[
//                                        Image.asset(
//                                          "assets/ab.png",
//                                          width: ScreenUtil().setWidth(24),
//                                          height: ScreenUtil().setHeight(24),
//                                        ),
//                                        Text("二维码")
//                                      ],
//                                    ),
//                                  )
                                  ],
                                ),
                              )
//          Image.asset("assets/ab.png",
//              width: ScreenUtil().setWidth(50),
//              height: ScreenUtil().setWidth(50)),
                          ),
//        onTap: () {
//          NaviUtil.push(
//              this.context,   PhotoViewGalleryScreen(images: images,index: 0,));
//        },
                        )),

                  ],
                )),
          ],
        ),
      );
    }
  }

  Widget slide(int ind) {

    return Container(
      color: Colors.white,
      height: ScreenUtil().setHeight(80),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          SizedBox(
            width: ScreenUtil().setWidth(21),
          ),
          Image.asset(
            "assets/assist/wenjian1.png",
            width: ScreenUtil().setWidth(55),
            height: ScreenUtil().setHeight(55),
          ),
          SizedBox(
            width: ScreenUtil().setWidth(23),
          ),
          Expanded(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  "${widget.taskSend[ind].name}",
                  style: TextStyle(
                      color: Color(
                        0xff101010,
                      ),
                      fontSize: ScreenUtil().setSp(14)),
                ),
//                SizedBox(
//                  height: ScreenUtil().setHeight(13),
//                ),
//                Row(
//                  children: <Widget>[
////                    Text(
////                      "15份素材",
////                      style: TextStyle(
////                          color: Color(0xffa3a3a3),
////                          fontSize: ScreenUtil().setSp(12)),
////                    ),
////                    SizedBox(
////                      width: ScreenUtil().setWidth(14),
////                    ),
////                    Text(
////                      "1.2MB",
////                      style: TextStyle(
////                          color: Color(0xffa3a3a3),
////                          fontSize: ScreenUtil().setSp(12)),
////                    ),
////                    SizedBox(
////                      width: ScreenUtil().setWidth(14),
////                    ),
//                    Text(
//                      "在架",
//                      style: TextStyle(
//                          color: Color(0xff00C91E),
//                          fontSize: ScreenUtil().setSp(12)),
//                    ),
//                  ],
//                )
              ],
            ),
          ),

//            Expanded(child: Text(""),),
          SizedBox(
            width: ScreenUtil().setWidth(10),
          ),
          Text(
            "展开",
            style: TextStyle(
                color: Color(0xffF94F68), fontSize: ScreenUtil().setSp(12)),
          ),
          SizedBox(
            width: ScreenUtil().setWidth(2),
          ),
          Image.asset(
            "assets/assist/sanjiao.png",
            width: ScreenUtil().setWidth(15),
            height: ScreenUtil().setHeight(15),
          ),
          SizedBox(
            width: ScreenUtil().setWidth(11),
          ),
        ],
      ),
    );

//    return Slidable(
////      controller: slidableController,
//      actionPane: SlidableDrawerActionPane(),
//      actionExtentRatio: 0.25,
//      child: Container(
//        color: Colors.white,
//        height: ScreenUtil().setHeight(80),
//        child: Row(
//          crossAxisAlignment: CrossAxisAlignment.center,
//          children: <Widget>[
//            SizedBox(
//              width: ScreenUtil().setWidth(21),
//            ),
//            Image.asset(
//              "assets/assist/wenjian1.png",
//              width: ScreenUtil().setWidth(55),
//              height: ScreenUtil().setHeight(55),
//            ),
//            SizedBox(
//              width: ScreenUtil().setWidth(23),
//            ),
//            Expanded(
//              child: Column(
//                mainAxisAlignment: MainAxisAlignment.center,
//                crossAxisAlignment: CrossAxisAlignment.start,
//                children: <Widget>[
//                  Text(
//                    "${widget.taskSend[ind].name}",
//                    style: TextStyle(
//                        color: Color(
//                          0xff101010,
//                        ),
//                        fontSize: ScreenUtil().setSp(14)),
//                  ),
//                  SizedBox(
//                    height: ScreenUtil().setHeight(13),
//                  ),
//                  Row(
//                    children: <Widget>[
//                      Text(
//                        "15份素材",
//                        style: TextStyle(
//                            color: Color(0xffa3a3a3),
//                            fontSize: ScreenUtil().setSp(12)),
//                      ),
//                      SizedBox(
//                        width: ScreenUtil().setWidth(14),
//                      ),
//                      Text(
//                        "1.2MB",
//                        style: TextStyle(
//                            color: Color(0xffa3a3a3),
//                            fontSize: ScreenUtil().setSp(12)),
//                      ),
//                      SizedBox(
//                        width: ScreenUtil().setWidth(14),
//                      ),
//                      Text(
//                        "在架",
//                        style: TextStyle(
//                            color: Color(0xff00C91E),
//                            fontSize: ScreenUtil().setSp(12)),
//                      ),
//                    ],
//                  )
//                ],
//              ),
//            ),
//
////            Expanded(child: Text(""),),
//            SizedBox(
//              width: ScreenUtil().setWidth(10),
//            ),
//            Text(
//              "展开",
//              style: TextStyle(
//                  color: Color(0xffF94F68), fontSize: ScreenUtil().setSp(12)),
//            ),
//            SizedBox(
//              width: ScreenUtil().setWidth(2),
//            ),
//            Image.asset(
//              "assets/assist/sanjiao.png",
//              width: ScreenUtil().setWidth(15),
//              height: ScreenUtil().setHeight(15),
//            ),
//            SizedBox(
//              width: ScreenUtil().setWidth(11),
//            ),
//          ],
//        ),
//      ),
//      secondaryActions: <Widget>[
//        GestureDetector(
//          child: Container(
//            width: ScreenUtil().setWidth(49),
//            height: ScreenUtil().setHeight(80),
//            color: Color(0xffFF94A4),
//            child: Column(
//              mainAxisAlignment: MainAxisAlignment.center,
//              children: <Widget>[
//                Image.asset(
//                  "assets/assist/shijianbai.png",
//                  width: ScreenUtil().setWidth(18),
//                  height: ScreenUtil().setHeight(18),
//                ),
//                SizedBox(
//                  height: ScreenUtil().setHeight(10),
//                ),
//                Text(
//                  "修改时间",
//                  style: TextStyle(
//                      color: Colors.white, fontSize: ScreenUtil().setSp(12)),
//                )
//              ],
//            ),
//          ),
//          onTap: () {
//            setTime1(widget.taskSend[ind].id);
//          },
//        ),
//        GestureDetector(
//          child: Container(
//            width: ScreenUtil().setWidth(49),
//            height: ScreenUtil().setHeight(80),
//            color: Color(0xffFF798D),
//            child: Column(
//              mainAxisAlignment: MainAxisAlignment.center,
//              children: <Widget>[
//                Image.asset(
//                  "assets/assist/chilun.png",
//                  width: ScreenUtil().setWidth(18),
//                  height: ScreenUtil().setHeight(18),
//                ),
//                SizedBox(
//                  height: ScreenUtil().setHeight(10),
//                ),
//                Text(
//                  "编辑",
//                  style: TextStyle(
//                      color: Colors.white, fontSize: ScreenUtil().setSp(12)),
//                )
//              ],
//            ),
//          ),
//          onTap: () {
//            NaviUtil.push(context,
//                PlanDetail(widget.taskSend[ind].info, widget.followdata,widget.taskSend[ind].name));
//          },
//        ),
//        GestureDetector(
//          child: Container(
//            width: ScreenUtil().setWidth(49),
//            height: ScreenUtil().setHeight(80),
//            color: Color(0xffF94F68),
//            child: Column(
//              mainAxisAlignment: MainAxisAlignment.center,
//              children: <Widget>[
//                Image.asset(
//                  "assets/assist/shanchu.png",
//                  width: ScreenUtil().setWidth(18),
//                  height: ScreenUtil().setHeight(18),
//                ),
//                SizedBox(
//                  height: ScreenUtil().setHeight(10),
//                ),
//                Text(
//                  "删除",
//                  style: TextStyle(
//                      color: Colors.white, fontSize: ScreenUtil().setSp(12)),
//                )
//              ],
//            ),
//          ),
//          onTap: () {
//            _showDeleteDialog(widget.taskSend[ind].name);
//          },
//        ),
//      ],
//    );
  }

  Timer timer;
  void update() {
    timer = Timer.periodic(Duration(milliseconds: 30), (timer) {
      bool change = false;
      for (int i = 0; i < widget.taskSend.length; i++) {
        RenderBox r = key[i].currentContext?.findRenderObject() as RenderBox;
        if (r?.size?.height != null) {
          if (heights[i] != null) {
            if (heights[i] != r?.size?.height) {
              change = true;
            }
          }
          heights[i] = r?.size?.height;
        }
//      print("${i}${heights[i]}");
//      print("${r?.size?.height}");

      }
      if (change) {
        setState(() {});
      }
    });
  }

  String missionName = "";
  String string = "";
  bool showdialog = false;
  OverlayEntry _overlayEntry = null;

  String time = "";
  Widget v(SomebodyOfficialPlanDataSendTaskInfo detailTemp) {
    return FutureBuilder<bool>(
      future: started(detailTemp),
      builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
        if (snapshot.data == true) {
          return Stack(
            children: <Widget>[
              AspectRatio(
                aspectRatio: detailTemp.controller.value.aspectRatio,
                child: VideoPlayer(detailTemp.controller),
              ),
              Positioned(
                child: Image.asset(
                  "assets/assist/shipin.png",
                  width: ScreenUtil().setWidth(30),
                  height: ScreenUtil().setHeight(30),
                ),
                left: ScreenUtil().setWidth(110),
                top: ScreenUtil().setHeight(110),
              )
            ],
          );
        } else {
          return const Text('正在加载视频');
        }
      },
    );
  }

  void setController() {
//    for(int j=0;j<widget.taskSend[i].info.length;j++){
//
//      if (widget.taskSend[i].info[j].type == 2) {
//        if (widget.taskSend[i].info[j].data.startsWith("http")) {
//          widget.taskSend[i].info[j]
//              .setController(VideoPlayerController.network(widget.taskSend[i].info[j].data));
//        } else {
//          widget.taskSend[i].info[j].setController(
//              VideoPlayerController.file(File(widget.taskSend[i].info[j].data)));
//        }
//      }
//
//
//    }

    for (int i = 0; i < widget.taskSend.length; i++) {
      key.add(GlobalKey());
//      list.add("呵呵呵${i}");
//      print("${key[i].toString()}");
//      List<GlobalKey> gk = List();
//      for (int j = 0; j < 10; j++) {
//        gk.add(GlobalKey());
//      }
//      k.add(gk);

      heights.add(ScreenUtil().setHeight(80 * 10).toDouble());

      for (int j = 0; j < widget.taskSend[i].info.length; j++) {
        if (widget.taskSend[i].info[j].type == 2) {
          if (widget.taskSend[i].info[j].data.startsWith("http")) {
            widget.taskSend[i].info[j].setController(
                VideoPlayerController.network(widget.taskSend[i].info[j].data));
          } else {
            widget.taskSend[i].info[j].setController(VideoPlayerController.file(
                File(widget.taskSend[i].info[j].data)));
          }
        }
      }
    }
  }

  Future<bool> started(SomebodyOfficialPlanDataSendTaskInfo detailTemp) async {
//    _controller = VideoPlayerController.network(
//        "https://www.runoob.com/try/demo_source/mov_bbb.mp4");
//      ..initialize().then((_) {
//        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
//        setState(() {});
//      });
//    await _controller.initialize();
//    await list[index].controller.initialize();
    await detailTemp.controller.initialize();
//    await _controller.play();
//    startedPlaying = true;
    return true;
  }

  TextEditingController missionNameController = TextEditingController();
  String groupId = "";


  void dialogcall(String group) {
    this.groupId = group;
  }

  void _showDeleteDialog(String delete) {
    DialogUtil.showdialog1(
        this.context,
        Container(
          width: ScreenUtil().setWidth(323),
          height: ScreenUtil().setHeight(216),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(
                height: ScreenUtil().setHeight(42),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Image.asset(
                    "assets/ab.png",
                    width: ScreenUtil().setWidth(24),
                    height: ScreenUtil().setHeight(24),
                  ),
                  Text(
                    "确定要删除",
                    style: TextStyle(
                        color: Color(0xff101010),
                        fontWeight: FontWeight.bold,
                        fontSize: ScreenUtil().setSp(16)),
                  ),
                ],
              ),
              Text(
                "${delete}任务包吗",
                style: TextStyle(
                    color: Color(0xff101010),
                    fontWeight: FontWeight.bold,
                    fontSize: ScreenUtil().setSp(16)),
              ),
              SizedBox(
                height: ScreenUtil().setHeight(42),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    width: ScreenUtil().setWidth(119),
                    height: ScreenUtil().setHeight(40),
                    alignment: Alignment.center,
                    decoration: redButtonStyleWithBorder,
                    child: Text(
                      "取消",
                      style: TextStyle(
                          color: Color(0xffFA657B),
                          fontSize: ScreenUtil().setSp(16)),
                    ),
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(15),
                  ),
                  Container(
                    width: ScreenUtil().setWidth(119),
                    height: ScreenUtil().setHeight(40),
                    alignment: Alignment.center,
                    decoration: redButtonStyle,
                    child: Text(
                      "确定",
                      style: TextStyle(
                          color: Colors.white,
                          fontSize: ScreenUtil().setSp(16)),
                    ),
                  ),
                ],
              )
            ],
          ),
        ),
        ScreenUtil().setHeight(216));
  }




}

